package leetcode;

/**
 * 题目：只出现一次的数字
 * 链接：https://leetcode.cn/problems/single-number/description/
 */
public class SingleNumber {
    public static void main(String[] args) {
        int[] arr = {4, 1, 2, 1, 2};
        System.out.println(singleNumber(arr));
    }
    public static int singleNumber(int[] nums) {
        int single = 0;
        for (int num : nums) {
            single ^= num;
        }
        return single;
    }
}
